package com.ld.control.business.equipment.controller;


import com.ld.control.business.equipment.service.EquipmentHolePositionConvertService;
import com.ld.control.business.equipment.vo.req.EquipmentHolePositionConvertReqVo;
import com.ld.control.business.equipment.vo.resp.EquipmentDataFieldConfigRespVo;
import com.ld.control.business.equipment.vo.resp.EquipmentHolePositionConvertRespVo;
import com.ld.control.common.PrimaryKeyReqVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GenerateListVo;
import com.ld.control.common.vo.GeneratePageListVo;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 设备孔位映射表 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-06-20
 */
@Tag(name = "设备孔位映射相关接口")
@RestController
public class EquipmentHolePositionConvertController {

    @Autowired
    private EquipmentHolePositionConvertService equipmentHolePositionConvertService;

    @GetMapping("/api/centralControl/equipmentHolePositionConvert/getPageList")
    @Operation(summary = "分页列表")
    public ResultResponse<GeneratePageListVo<EquipmentHolePositionConvertRespVo>> getPageList(
            @Parameter(description = "设备ID") Long equipmentId,
            @Parameter(description = "当前页") @RequestParam(defaultValue = "1") Integer current,
            @Parameter(description = "页大小") @RequestParam(defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<EquipmentHolePositionConvertRespVo> pageList = equipmentHolePositionConvertService.getPageList(equipmentId, current, size);
        return ResultResponse.success(pageList);
    }


    @PostMapping("/api/centralControl/equipmentHolePositionConvert/add")
    @Operation(summary = "添加")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody EquipmentHolePositionConvertReqVo reqVo
    ) {
        equipmentHolePositionConvertService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/equipmentHolePositionConvert/update")
    @Operation(summary = "修改")
    public ResultResponse<ResultResponseEnum> update(
            @RequestBody EquipmentHolePositionConvertReqVo reqVo
    ) {
        equipmentHolePositionConvertService.updateById(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/equipmentHolePositionConvert/delete")
    @Operation(summary = "删除")
    public ResultResponse<ResultResponseEnum> delete(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        equipmentHolePositionConvertService.deleteById(reqVo.getId());
        return ResultResponse.success();
    }

    @GetMapping("/api/centralControl/equipmentHolePositionConvert/getById")
    @Operation(summary = "获取详情")
    public ResultResponse<EquipmentHolePositionConvertRespVo> getById(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        EquipmentHolePositionConvertRespVo respVo = equipmentHolePositionConvertService.getById(reqVo.getId());
        return ResultResponse.success(respVo);
    }
}

